import requests


def login(username, password):
    url = 'http://192.168.132.131:38000/api2/auth-token/'
    header = {'content-type': 'application/x-www-form-urlencoded'}
    body = {'username': username, 'password': password}
    resp = requests.post(url, headers=header, data=body)
    print(f'获取响应状态码{resp.status_code}')
    print(f'获取响应头{resp.headers}')
    print(f'获取响应体{resp.text}')
    print(f'获取响应时间{resp.elapsed.total_seconds()}')


login('seafile@admin.com', 'admin')
print('*'*100)
login('', 'admin')
print('*'*100)
login('seafile@admin.com', '')
print('*'*100)
login('', '')
